package app.softtech.freechat;

import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import app.softtech.freechat.adapter.FriendRequestAdapter;
import app.softtech.freechat.database.DatabaseFriend;
import app.softtech.freechat.database.DatabaseHanler;

public class ActivityFriendRequest extends Activity {
	
	//Fields
	private ListView mListViewRequestFriend;
	private FriendRequestAdapter mAdapter;
	private List<DatabaseFriend> mListRequestFriend;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_friend_request);
		DatabaseHanler db = new DatabaseHanler(getApplicationContext());
		mListRequestFriend = db.getAllFriendRequest();
		
		mListViewRequestFriend = (ListView) findViewById(R.id.lv_friend_request);
		mAdapter = new FriendRequestAdapter(this, mListRequestFriend);
		mListViewRequestFriend.setAdapter(mAdapter);
		
		//For test
		Button btnTest = (Button) findViewById(R.id.btn_for_test);
		btnTest.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent i = new Intent(ActivityFriendRequest.this, MainActivity.class);
				startActivity(i);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_friend_request, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
